home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / cit.arc / CTDL.H < prev    next >
C/C++ Source or Header  |  1986-01-10  |  16KB  |  449 lines

  1. /************************************************************************/
  2. /*                Ctdl.h                    */
  3. /*    #include file for all Citadel C files.                */
  4. /*    Now includes only #defines and structs.             */
  5. /************************************************************************/
  6.  
  7. #define  _C86_BIG  1
  8. #include "stdio.h"
  9.  
  10. /************************************************************************/
  11. /* 85Oct16 HAW    Add code for OFFICE-STUFF parameter.            */
  12. /* 85Aug29 HAW    Install code to allow double msg files for autobackup.    */
  13. /* 85Jun19 HAW    Implant exit values so batch files can be made useful.    */
  14. /* 85May27 HAW    Start adding networking gunk.                */
  15. /* 85May22 HAW    MAXLOGTAB now sysop selectable.             */
  16. /* 85May06 HAW    Add daily bailout parameter.                */
  17. /* 85May05 HAW    Add SYSDISK parameter.                    */
  18. /* 85Mar20 HAW    Add timestamp code.                    */
  19. /* 85Feb21 HAW    Add directory names.                    */
  20. /* 85Feb20 HAW    Implement IMPERVIOUS flag.                */
  21. /* 85Feb18 HAW    Insert global variables for baud search.        */
  22. /* 85Jan20 HAW    Insert code to read from system clock.            */
  23. /* 84Aug30 HAW    Begin conversion to MS-DOS                */
  24. /*                                    */
  25. /*                #defines        82Dec10 dvm    */
  26. /*                                    */
  27. /* #defs supported in current system:                    */
  28. /*                                    */
  29. /* #def FDC-1 for the TeleTek (dvm code)                */
  30. /* #def VFC-2 for the Big Board (dvm code)                */
  31. /*                                    */
  32. /* #def TEST for special small-scale test version            */
  33. /************************************************************************/
  34.  
  35. #define ulong    unsigned long    /* Makes it easier to format        */
  36. #define MSDOS    1
  37.  
  38. #define NAMESIZE       20    /* length of room names         */
  39.  
  40. typedef char label[NAMESIZE];
  41.  
  42. /* Citadel programs use readSysTab() and writeSysTab() to write an    */
  43. /* image of the external variables in RAM to disk, and later restore    */
  44. /* it.    The image is stored in ctdlTabl.sys .  If ctdlTabl.sys is lost, */
  45. /* confg.com will automatically reconstruct the hard way when invoked,    */
  46. /* and write a new ctdlTabl.sys out when finished.  CtdlTabl.sys is    */
  47. /* always destroyed after reading, to minimize the possibility of    */
  48. /* reading an out-of-date version.  In general, the technique works    */
  49. /* well and saves time and head-banging on bootup.  You should,     */
  50. /* however, note carefully the following caution:            */
  51. /*  o  Whenever you change the declarations in Ctdl.h you should:    */
  52. /*   -->  destroy the current ctdlTabl.sys file             */
  53. /*   -->  recompile and reload all citadel programs which access    */
  54. /*      ctdlTabl.sys -- currently citadel.com & configur.com        */
  55. /*   -->  use configur.com to build a new ctdlTabl.sys file        */
  56. /*                                    */
  57. /* If you ignore these warnings, little pixies will prick you in your    */
  58. /* sleep for the rest of your life.                    */
  59. /************************************************************************/
  60.  
  61.         /* Let's begin by defining the configuration struct.    */
  62.         /* This is part of the contents of ctdltabl.sys     */
  63. struct config {
  64.     char firstExtern;
  65.  
  66.     unsigned maxMSector;    /* Max # of sectors (simulated)     */
  67.  
  68.     char megaHz;        /* 8088 clock rate (for wait loops)    */
  69.  
  70.     ulong oldest;        /* 32-bit ID# of first message in system*/
  71.     ulong newest;        /* 32-bit ID# of last  message in system*/
  72.  
  73.     int  nodeName;        /* Offsets in codeBuf            */
  74.     int  nodeTitle;
  75.     int  nodeId;
  76.     int  bRoom;
  77.     int  officeStuff;
  78.  
  79.     char noChat;        /* TRUE to suppress chat attempts    */
  80.  
  81.     int  cryptSeed;
  82. #ifndef MSDOS
  83.     char clock;         /* TRUE  if we have a hardware clock    */
  84. #endif
  85.  
  86.     char search_baud;        /* TRUE to do flip flop search for baud */
  87.     char IBM_or_clone;        /* Specialize for Sperry PC <sigh>    */
  88.  
  89.     char dailyTimeout;        /* Do we want to bail out on a daily    */
  90.     int  hourOut;        /* basis? When?             */
  91.  
  92.     char call_log;        /* if < 100, indicates drive for log    */
  93.  
  94.     char mirror;        /* Auto backup of message files?    */
  95.     char mbkpDisk;        /* Where is this file located?        */
  96.  
  97.     char filter[128];        /* input character translation table    */
  98.  
  99.     char homeDisk, msgDisk, sysDisk;/* where we keep our data files    */
  100.     char netDisk;        /* where we want to find net files    */
  101.     char ourDisk;        /* where we are just now        */
  102.     char ourUser[10];
  103.  
  104.     char unlogEnterOk;        /* TRUE if OK to enter messages anon    */
  105.     char unlogReadOk;        /* TRUE if unlogged folks can read mess */
  106.     char unlogLoginOk;        /* TRUE if spontan. new accounts ok.    */
  107.     char nonAideRoomOk;     /* TRUE general folks can make rooms    */
  108.     char noMail;        /* TRUE if mail is not allowed        */
  109.  
  110.     char sysBaud;
  111.  
  112.     char netParticipant;    /* TRUE if participating in the net    */
  113.     char longHaul;        /* TRUE if willing to do long distance    */
  114.     char dayDiv;        /* Days to network on            */
  115.     char netHour;        /* Hour to start networking on        */
  116.     char netLength;        /* Length of networking         */
  117.     int  netSize;
  118.  
  119. /*    stuff to distinguish the various Citadel programs        */
  120. #define CITADEL     0    /* principal program            */
  121. #define xxxxx        1    /* unused                */
  122. #define NET        2    /* network downloader            */
  123. #define ARCHIVE     3    /* backup program    (future)    */
  124. #define CONFIGUR    4
  125. #define UTILITY     5
  126.     char    weAre;        /* set first thing by main()        */
  127.     int     paramVers;
  128.  
  129. /*            Stuff to size system with:            */
  130. /* WARNING!!! if you expand MAXROOMS beyond 128, horrible, horrible    */
  131. /* things will happen to the userlog entries, which will no longer    */
  132. /* fit in the assigned 256-byte records and will overwrite things    */
  133. /* with normally undesirable results. 82Nov10CrT            */
  134.  
  135. #define MAXROOMS       64    /* number of rooms allowed in system    */
  136.  
  137.     int MAXLOGTAB;        /* number of log entries supported    */
  138.  
  139.  
  140. /*        Stuff nowadays usually in bdscio.h:            */
  141. /* values for functions to return: */
  142. #define TRUE        1
  143. #define FALSE        0
  144. #define ERROR           -1
  145.  
  146. #define SAMESTRING    0    /* value for strcmp() & friend        */
  147.  
  148. /* ASCII characters: */
  149. #define SOH        1
  150. #define CNTRLC        3
  151. #define EOT        4
  152. #define ACK        6
  153. #define BELL        7
  154. #define BACKSPACE    8
  155. #define CNTRLI        9    /* aka tab                */
  156. #define TAB        9    /* aka ^I                */
  157. #define NEWLINE        10    /* "linefeed" to philistines.        */
  158. #define CNTRLO           15
  159. #define CNTRLl           12    /* Sysop privileges            */
  160. #define XOFF           19    /* control-s                */
  161. #define NAK           21
  162. #define CAN           24
  163. #define CNTRLZ           26
  164. #define CPMEOF       CNTRLZ
  165. #define ESC           27    /* altmode                */
  166. #define DEL         0x7F    /* delete char                */
  167.  
  168. /*            Stuff for rooms:                */
  169. #define LOBBY        0    /* Lobby> is >always< room 0.        */
  170. #define MAILROOM    1    /* Mail>  is >always< room 1.        */
  171. #define AIDEROOM    2    /* Aide> is >always< room 2.        */
  172.  
  173. #ifdef TEST
  174. #define MSGSPERRM      58    /* should be >= MAILSLOTS        */
  175. #else
  176. #define MSGSPERRM      58    /* roombuf must be 256 bytes or less.    */
  177. #endif
  178.  
  179. #define SECTSIZE      128
  180.  
  181. #define MAXCODE       512
  182.     unsigned char codeBuf[MAXCODE];/* buffer for configuration routines */
  183.     unsigned char scratch[40];    /* scratch space for config routines    */
  184.     unsigned char shave[8];    /* shave-and-a-haircut/2 bits pauses    */
  185.  
  186. /* routine offsets in codeBuf: */
  187.     int pBauds[3];        /* Indexes into here defined later    */
  188.     int pHangUp, pCarrDetect, pMIReady, pMOReady, pInitPort;
  189.     int pCheckBaud;
  190. #ifndef MSDOS        /* MSDOS has and uses system clock, so if using */
  191.             /* it, don't need this stuff.            */
  192.     int pInitDate, pGetDay, pGetMonth, pGetYear;
  193. #endif
  194.     int  catChar;
  195.     unsigned catSector;
  196.  
  197.     char debug;         /* turns debug printout on and off    */
  198.  
  199.     int  sizeLTentry;        /* contains size of a logTab entry    */
  200.  
  201.     char lastExtern;
  202. } ;             /* And that's all of the variables we want to save */
  203.  
  204. /************************************************************************/
  205. /*                  Room data                */
  206. /************************************************************************/
  207. #define UNREAD        0    /* Only list unread rooms        */
  208. #define ALMOST_ALL    1    /* List both unread and read rooms    */
  209. #define FORGOT        2    /* List forgotten public rooms        */
  210.  
  211. struct rflags {         /* Room flags                */
  212.     unsigned INUSE    : 1;    /* Room in use?             */
  213.     unsigned PUBLIC   : 1;    /* Room public?             */
  214.     unsigned MSDOSDIR : 1;    /* Room directory?            */
  215.     unsigned PERMROOM : 1;    /* Room permanent?            */
  216.     unsigned SKIP     : 1;    /* Room skipped? (temporary for user)    */
  217.     unsigned YUCK     : 0;    /* Force realignment I guess.        */
  218. } ;
  219.  
  220. struct rTable {         /* The summation of a room        */
  221.     unsigned char rtgen;    /* generation # of room         */
  222.     struct rflags rtflags;    /* public/private flag etc        */
  223.     label      rtname;    /* name of room             */
  224.     ulong      rtlastMessage;/* # of most recent message in room    */
  225. } ;                /* And see ROOMA.C for declaration    */
  226.  
  227. struct aRoom {            /* The appearance of a room:        */
  228.     unsigned char rbgen;    /* generation # of room         */
  229.     struct rflags rbflags;    /* same bits as flags above        */
  230.     label      rbname;    /* name of room             */
  231.     char      rbdisk;    /* disk this rooms files are in 0=>none */
  232.     char      rbdirname[9]; /* user directory for this room's files */
  233.     struct {
  234.     ulong rbmsgNo;        /* every message gets unique#        */
  235.     unsigned rbmsgLoc;    /* sector message starts in        */
  236.     } msg[MSGSPERRM];
  237. } ;                /* And see ROOMA.C for declaration    */
  238.  
  239. /************************************************************************/
  240. /*                  userlog stuff                */
  241. /************************************************************************/
  242. #define CRYPTADD      117    /*                    */
  243.  
  244. struct lflags {         /* Flags for person in log        */
  245.     unsigned UCMASK    : 1;    /* Uppercase?                */
  246.     unsigned LFMASK    : 1;    /* Linefeeds?                */
  247.     unsigned EXPERT    : 1;    /* Expert?                */
  248.     unsigned AIDE      : 1;    /* Vice-Grand-Poobah?            */
  249.     unsigned L_INUSE   : 1;    /* Is this slot in use?         */
  250.     unsigned TIME      : 1;    /* Send time to user of msg creation?    */
  251.     unsigned OLDTOO    : 1;    /* Print out last oldmessage on <N>ew?    */
  252.     unsigned NET_PRIVS : 1;    /* User have net privileges?        */
  253.     unsigned RUGGIE    : 1;    /* Juvenile? Future fun-ness        */
  254.     unsigned YUCK      : 0;    /* Force realignment    ???        */
  255. } ;
  256.  
  257. #define MAILSLOTS      58    /* Same as normal room            */
  258.  
  259. #define MAXVISIT    8    /* #visits we remember old newestLo for */
  260. #define MAXGEN           32    /* six bits of generation => 64 of them */
  261. #define FORGET_OFFSET  (MAXGEN / 2)    /* For forgetting rooms     */
  262.  
  263. #define GENSHIFT    3    /* Where the generation # is        */
  264. #define CALLMASK    7    /* For finding last visit        */
  265.  
  266. struct logBuffer {        /* The appearance of a user:        */
  267.     unsigned char lbnulls;    /* #nulls, lCase, lFeeds        */
  268.     struct lflags lbflags;    /* UCMASK, LFMASK, EXPERT, AIDE, INUSE    */
  269.     unsigned char lbwidth;    /* terminal width            */
  270.     char      credit;    /* Credit for long distance calls    */
  271.     label      lbname;    /* caller's name            */
  272.     label      lbpw;     /* caller's password            */
  273.     unsigned char lbgen[MAXROOMS];/* 5 bits gen, 3 bits lastvisit    */
  274.     ulong     lbvisit[MAXVISIT];/* newestLo for this and 3 prev. visits */
  275.     unsigned  lbslot[MAILSLOTS];/* for private mail            */
  276.     ulong     lbId[MAILSLOTS];    /* for private mail            */
  277. } ;                /* And see LOG.C for declaration    */
  278.  
  279. struct lTable {         /* Summation of a person:        */
  280.     int   ltpwhash;        /* hash of password            */
  281.     int   ltnmhash;        /* hash of name             */
  282.     int   ltlogSlot;        /* location in userlog.buf        */
  283.     ulong ltnewest;        /* last message on last call        */
  284. } ;                /* And see LOG.C for declaration    */
  285.  
  286. /************************************************************************/
  287. /*            terminal stuff                    */
  288. /************************************************************************/
  289. #define SPECIAL        27    /* <ESC>    console escape char    */
  290.  
  291. /************************************************************************/
  292. /*            message stuff                    */
  293. /************************************************************************/
  294. #define MAXTEXT      7500    /* maximum chars in edit buffer     */
  295.  
  296. #define HELD 3
  297.  
  298. struct msgB {            /* This is what a msg looks like    */
  299.     int  Ooops;
  300.     char mbtext[MAXTEXT]  ;    /* buffer text is edited in        */
  301.  
  302.     int  mbheadChar      ;    /* start of message            */
  303.     unsigned     mbheadSector;    /* start of message            */
  304.  
  305.     label mbauth ;        /* name of author            */
  306.     label mbdate ;        /* creation date            */
  307.     label mbtime ;        /* creation time            */
  308.     label mbId     ;        /* local number of message        */
  309.     label mboname;        /* short human name for origin system    */
  310.     label mborig ;        /* US xxx xxx xxxx style ID        */
  311.     label mbroom ;        /* creation room            */
  312.     label mbsrcId;        /* message ID on system of origin    */
  313.     label mbto     ;        /* private message to            */
  314.     label mbaddr ;        /* address of system for net routing    */
  315. } ;                /* declaration in MSG.C         */
  316.  
  317. /* values for showMess routine */
  318. #define NEWoNLY     0
  319. #define OLDaNDnEW    1
  320. #define OLDoNLY     2
  321. #define GLOBALnEW    3
  322.  
  323. /************************************************************************/
  324. /*            modem stuff                    */
  325. /************************************************************************/
  326. /* somestuff readfile() and sendfile() like:    */
  327. #define LOOPSPERSEC  5000
  328. #define ERRORMAX       10
  329. #define RETRYMAX       10
  330.  
  331. /* fiddle factor to timeout on no input: */
  332. #define HITIMEOUT    7276    /* processor dependent, see MODEM.C    */
  333.  
  334. #define NEWCARRIER   0x01    /* returned to main prog on login    */
  335.  
  336. #define MODEM        0    /* current user of system is        */
  337. #define CONSOLE     1    /* one of these             */
  338.  
  339. /*  output XON/XOFF etc flag... */
  340. #define OUTOK        0    /* normal output            */
  341. #define OUTPAUSE    1    /* a pause has been requested        */
  342. #define OUTNEXT     2    /* quit this message, get the next    */
  343. #define OUTSKIP     3    /* stop current process         */
  344. #define OUTPARAGRAPH    4    /* skip to next paragraph        */
  345. #define IMPERVIOUS    5    /* make current output unstoppable    */
  346.  
  347. #define NEITHER     0    /* don't echo input at all        */
  348. #define CALLER        1    /* echo to caller only --passwords etc    */
  349. #define BOTH        2    /* echo to caller and console both    */
  350.  
  351. #define NO_ECHO     0    /* Echo input as X's            */
  352. #define ECHO        1    /* Echo input    (getString())        */
  353.  
  354.  
  355. /*    stuff for the mini-INTRPreter that drives the modem:        */
  356. /* opcodes for the interpreter: */
  357. #define ANDI        1
  358. #define INP        2
  359. #define LOAD        3
  360. #define LOADI        4
  361. #define ORI        5
  362. #define OUTP        6
  363. #define OUTSTRING    7
  364. #define PAUSEI        8
  365. #define RET        9
  366. #define STORE           10
  367. #define XORI           11
  368. #define STOREX           12
  369. #define LOADX           13
  370. #define OPRNUMBER      14
  371. #define TOBDC           15
  372. #define TODEC           16
  373.                     /* For system calls.        */
  374. struct regval {int ax, bx, cx, dx, si, di, ds, es; };
  375.  
  376. #define STARTUP 1
  377. #define FINISH    2
  378.  
  379. /************************************************************************/
  380. /*            net stuff                    */
  381. /************************************************************************/
  382.  
  383. #define ONLY_300    0
  384. #define BOTH_300_1200    1
  385. #define TH_3_12_24    2
  386.  
  387. #define HANGUP        0
  388. #define NORMAL_MAIL    1
  389. #define R_FILE_REQ    2
  390.  
  391. #define BAD        0
  392. #define GOOD        1
  393.  
  394. struct nflags {         /* Any and all reasons to call this node*/
  395.     unsigned normal_mail : 1;
  396.     unsigned in_use     : 1;
  397.     unsigned room_files  : 1;
  398.     unsigned realign     : 0;
  399. } ;
  400.  
  401. struct netBuffer {
  402.     label      netId;
  403.     label      netName;
  404.     struct nflags nbflags;
  405.     char      baudCode;
  406. } ;
  407.  
  408. struct netTable {
  409.     int       ntnmhash;
  410.     int       ntidhash;
  411.     struct nflags ntflags ;
  412. } ;
  413.  
  414. struct cmd_data {        /* Commands for networking        */
  415.     unsigned char command;
  416.     char      fields[4][NAMESIZE];
  417. } ;
  418.  
  419. struct fl_req {
  420.     label room;
  421.     label roomfile;
  422.     char  drive;
  423.     char  path[100];
  424.     label filename;
  425. } ;
  426.  
  427. /************************************************************************/
  428. /*            Exit values                    */
  429. /************************************************************************/
  430. #define SYSOP_EXIT    0
  431. #define TIME_EXIT    1
  432. #define CRASH_EXIT    2
  433.  
  434. /************************************************************************/
  435. /*            Useful psuedo functions             */
  436. /************************************************************************/
  437.  
  438. #define gotCarrier()    interpret(cfg.pCarrDetect)
  439.  
  440. #define onLine()    (haveCarrier    ||   onConsole)
  441.  
  442. /************************************************************************/
  443. /*            Call log stuff                    */
  444. /************************************************************************/
  445. #define BAUD        0
  446. #define L_IN        1
  447. #define L_OUT        2
  448. #define CARRLOSS    3
  449.